<template>
  <div>
    <el-card class="box-card" style="width: 1180px">
      <div slot="header" class="clearfix">
        <el-form :inline="true" :model="query">
          <el-form-item>
            <el-input
              v-model="query.realName"
              placeholder="用户名"
              :clearable="true"
              @clear="querykey"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="load"
              ><i class="el-icon-search"></i
            ></el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="oId" label="订单编号" width="90">
        </el-table-column>
        <el-table-column prop="oName" label="订单名称" width="120">
        </el-table-column>
        <el-table-column prop="user.uName" label="用户名" width="120">
        </el-table-column>
        <el-table-column prop="oTimestart" label="开始时间" width="140">
        </el-table-column>
        <el-table-column prop="oTimeend" label="结束时间" width="140">
        </el-table-column>
        <el-table-column prop="cheweiId" label="车位编号" width="100">
        </el-table-column>
        <el-table-column prop="oBeiyong2" label="总时长" width="115">
        </el-table-column>
        <el-table-column prop="oConsumption" label="总消费" width="80">
        </el-table-column>
        <el-table-column prop="oState" label="订单状态" width="90">
          <template slot-scope="scope">
            <p
              v-if="tableData[scope.$index].oState == 1"
              style="color: #ff4949"
            >
              进行中
            </p>
            <p
              v-if="tableData[scope.$index].oState == 2"
              style="color: #3bc053"
            >
              未支付
            </p>
            <p
              v-if="tableData[scope.$index].oState == 3"
              style="color: #3740b7"
            >
              已支付
            </p>
          </template>
        </el-table-column>

        <el-table-column label="操作" width="140" align="center">
          <template slot-scope="scope">
            <el-button type="primary" @click="updateUI(scope.row)"
              >查看用户信息</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <!-- 添加模态框开始 -->

      <el-dialog title="用户信息" :visible.sync="dialogFormVisible" width="65%">
        <el-form :model="form">
          <el-descriptions title="" :column="3" border>
            <el-descriptions-item
              label="用户名"
              label-class-name="my-label"
              content-class-name="my-content"
            >
              <el-input
                v-model="form.uName"
                autocomplete="off"
                style="color: red"
              ></el-input>
            </el-descriptions-item>
            <el-descriptions-item
              label="手机号"
              label-class-name="my-label1"
              content-class-name="my-content1"
              ><el-input v-model="form.uTel" autocomplete="off"></el-input
            ></el-descriptions-item>
            <el-descriptions-item
              label="昵称"
              label-class-name="my-label"
              content-class-name="my-content"
              ><el-input v-model="form.uNickname" autocomplete="off"></el-input
            ></el-descriptions-item>

            <el-descriptions-item
              label="积分"
              label-class-name="my-label1"
              content-class-name="my-content1"
              ><el-input v-model="form.uIntegral" autocomplete="off"></el-input
            ></el-descriptions-item>
            <el-descriptions-item
              label="余额"
              label-class-name="my-label"
              content-class-name="my-content"
              ><el-input v-model="form.uBalance" autocomplete="off"></el-input
            ></el-descriptions-item>
            <el-descriptions-item
              label="邮箱"
              label-class-name="my-label1"
              content-class-name="my-content1"
              ><el-input v-model="form.uEmail" autocomplete="off"></el-input
            ></el-descriptions-item>

            <el-descriptions-item
              label="身份证号"
              label-class-name="my-label1"
              content-class-name="my-content1"
              ><el-input v-model="form.uCardid" autocomplete="off"></el-input
            ></el-descriptions-item>

            <el-descriptions-item
              label="联系地址"
              :contentStyle="{ 'text-align': 'right' }"
              label-class-name="my-label2"
              content-class-name="my-content2"
              ><el-input v-model="form.uAddress" autocomplete="off"></el-input
            ></el-descriptions-item>
          </el-descriptions>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="dialogFormVisible = false"
            >取 消</el-button
          >
        </div>
      </el-dialog>
      <!-- 添加模态框结束 -->

      <!--分页的实现-->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageInfo.currentPage"
        :page-sizes="pageInfo.pageSizeS"
        :page-size="pageInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageInfo.total"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      deptList: [],
      tableData: [],
      query: {},
      dialogFormVisible: false,
      pageInfo: {
        currentPage: 1,
        pageSizeS: [5, 10, 20, 50],
        pageSize: 5,
        total: 1,
      },
      form: {
        uName: "",
        uTel: "",
        uAddress: "",
        uBalance: "",
        uIntegral: "",
        uEmail: "",
        uState: "",
        uCardid: "",
        uNickname: "",
      },
      updateForm: {},
      formLabelWidth: "180px",
      dialog: {
        addshow: false,
        updateshow: false,
      },
    };
  },
  methods: {
    updateUI(row) {
      this.dialogFormVisible = true;
      this.form = row.user;
    },

    querykey() {
      this.load();
    },

    //当下拉列表改变时
    handleSizeChange(size) {
      this.pageInfo.pageSize = size;

      this.load();
    },
    //当点击页数触发
    handleCurrentChange(size) {
      this.pageInfo.currentPage = size;

      this.load();
    },

    load() {
      console.log(this.query.realName);
      this.$axios
        .post("orders/findAllOWU", {
          msg: this.query.realName,
          currentPage: this.pageInfo.currentPage,
          pageSize: this.pageInfo.pageSize,
        })
        .then((res) => {
          console.log(res.data.data);
          this.tableData = res.data.data.list; //当前页数据
          this.pageInfo.total = res.data.data.total; //得到满足条件的数据条数
        })
        .catch((error) => {
          this.$message.error("出错了，请稍后重试");
        });
    },
  },
  mounted: function () {
    this.load();
  },
};
</script>
<style scoped>
h1,
.box-card {
  margin: auto;
  width: 60%;
}

.el-form-item {
  margin-bottom: 0;
}

[v-cloak] {
  display: none;
}
.uoloadSty .el-upload--picture-card {
  width: 110px;
  height: 110px;
  line-height: 110px;
}

.my-label {
  background: #e1f3d8;
}

/* .my-content {
    background: #FDE2E2;
  }
  .my-label1 {
    background: #93dbe5;
  }

  .my-content1 {
    background: #93dbe5;
  }
   .my-label2 {
    background: #b98eec;
  }

  .my-content2 {
    background: #b98eec;
  } */
</style>